#include <stdio.h>
#include <string.h>

int main() {
    int i, j, n = 5;
    char temp[7];
    char color[5][7] = {"red", "blue", "yellow", "green", "purple"};
    for (i = 0; i < n - 1; i++)
        for (j = i + 1; j < n; j++)
            //如果比较两个字符串的大小，返回值大于0，则表示第一个字符串大于第二个字符串 按照升序排序,则需要交换位置
            if (strcmp(color[i], color[j]) > 0) {
                strcpy(temp, color[i]);
                strcpy(color[i], color[j]);
                strcpy(color[j], temp);
            }
    for (i = 0; i < 5; i++)
        printf("%s ", color[i]);
    return 0;
}